<?php

namespace plugin\property\app\model;

class PropertyRole extends \plugin\owladmin\app\model\AdminRole
{
    protected $table = 'property_admin_roles';


    public function permissions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
    {
        return $this->belongsToMany(PropertyPermission::class, 'property_admin_role_permissions', 'role_id', 'permission_id')
            ->withTimestamps();
    }

    protected static function boot(): void
    {
        parent::boot();
        static::deleting(function (PropertyRole $model) {
            $model->permissions()->detach();
        });
    }
}